package ha.dal.dao.realtime.test;

import ha.dal.dao.test.AbstractDataAccessTests;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.time.DateUtils;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import com.smartwebx.ha.dal.inter.water.IQProcessDataOperatDao;
import com.smartwebx.ha.dal.realtime.dao.WasMapper;
import com.smartwebx.ha.dal.usebean.DateValue;

public class WasMapperTes extends AbstractDataAccessTests {
	@Autowired
	private WasMapper wasDao;

	private String stcd = "51110300";

	private static String datePointStr = "2011-08-04";
	private static Date datePoint;

	private static String startDayStr = "2011-08-04";
	private static String endDayStr = "2011-08-05";
	private static Date startDayDate;
	private static Date endDayDate;

	private static String startHourStr = "2011-08-02 07:00";
	private static String endHourStr = "2011-08-02 20:00";
	private static Date startHour;
	private static Date endHour;

	private static String dateFormat = "yyyy-MM-dd";
	private static String dateHourFormat1 = "yyyy-MM-dd HH:mm:ss";
	private static String dateHourFormat2 = "yyyy-MM-dd HH:mm";

	@BeforeClass
	public static void beforeClass() throws ParseException {
		datePoint = DateUtils.parseDate(datePointStr, dateFormat);

		startDayDate = DateUtils.parseDate(startDayStr, dateFormat);
		endDayDate = DateUtils.parseDate(endDayStr, dateFormat);

		startHour = DateUtils.parseDate(startHourStr, dateHourFormat1,
				dateHourFormat2);
		endHour = DateUtils.parseDate(endHourStr, dateHourFormat1,
				dateHourFormat2);
	}
	
	
	
	@Test
	public void getSingleStatHourZProcess() {
		List<DateValue> results = wasDao.getSingleStatHourZProcess(stcd, startHour,
				endHour);
		Assert.assertNotNull(results);
	}

	@Test
	public void getStartHourBeforeZVal() {
		DateValue result = wasDao.getStartHourBeforeQVal(stcd, datePoint);
		Assert.assertNotNull(result);
	}

	@Test
	public void getSingleStatDayZProcess() {
		List<DateValue> results = wasDao.getSingleStatDayZProcess(stcd,
				startDayDate, endDayDate);
		Assert.assertNotNull(results);
	}

	@Test
	public void getSingleStatHourQProcess() {
		List<DateValue> results = wasDao.getSingleStatHourQProcess(stcd, startHour,
				endHour);
		Assert.assertNotNull(results);
	}

	@Test
	public void getStartHourBeforeQVal() {
		DateValue result = ((IQProcessDataOperatDao)wasDao).getStartHourBeforeQVal(stcd, datePoint);
		Assert.assertNotNull(result);
	}

	@Test
	public void getSingleStatDayQProcess() {
		List<DateValue> results = wasDao.getSingleStatDayQProcess(stcd,
				startDayDate, endDayDate);
		Assert.assertNotNull(results);
	}
}
